<?php
namespace app\common\services;

use Yii;

/**
 * Class StaticService 静态资源服务器
 * Author: yanhaoqiang
 * @package app\common\services
 */
class StaticService {

    /**
     * [includeAppStatic 设定基本数据]
     * @param $type
     * @param $path
     * @param $depend
     * @return void
     */
    public static function includeAppStatic($type, $path, $depend) {
        $release_version = defined("RELEASE_VERSION") ? RELEASE_VERSION : "20150731141600";
        $path = $path . "?ver={$release_version}";
        if ($type == "css") {
            Yii::$app->getView()->registerCssFile($path, ['depends' => $depend]);
        } else {
            Yii::$app->getView()->registerJsFile($path, ['depends' => $depend]);
        }
    }

    /**
     * [includeAppJsStatic 引入 js 数据]
     * @param $path
     * @param $depend
     * @return void
     */
    public static function includeAppJsStatic($path, $depend) {
        self::includeAppStatic("js", $path, $depend);
    }

    /**
     * [includeAppCssStatic 引入 css 数据]
     * @param $path
     * @param $depend
     * @return void
     */
    public static function includeAppCssStatic($path, $depend) {
        self::includeAppStatic("css", $path, $depend);
    }
}